package com.umeng.comm.ui.adapters;

import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.view.View;

import com.qianxx.base.utils.StringUtil;
import com.qianxx.base.utils.TimeUtil;
import com.umeng.comm.core.beans.CommUser;
import com.umeng.comm.core.beans.Comment;
import com.umeng.comm.core.beans.Like;
import com.umeng.comm.core.constants.Constants;
import com.umeng.comm.core.utils.CommonUtils;
import com.umeng.comm.core.utils.ResFinder;
import com.umeng.comm.core.utils.TimeUtils;
import com.umeng.comm.ui.activities.UserInfoActivity;
import com.umeng.comm.ui.adapters.viewholders.FeedCommentViewHolder;
import com.umeng.comm.ui.adapters.viewholders.FeedLikeViewHolder;
import com.umeng.comm.ui.imagepicker.adapters.CommonAdapter;
import com.umeng.comm.ui.imagepicker.listener.LikeMoreonClickListener;
import com.umeng.community.example.Utils.OtherUserRequestUtils;
import com.umeng.community.example.bean.Info;
import com.umeng.community.example.bean.MyInfo;

/**
 * Created by wangfei on 16/1/25.
 */
public class FeedLikeAdapter extends CommonAdapter<Like, FeedLikeViewHolder> {

    private MyInfo info;

    @Override
    protected FeedLikeViewHolder createViewHolder() {
        return new FeedLikeViewHolder();
    }

    @Override
    protected void setItemData(int position, FeedLikeViewHolder viewHolder, View rootView) {
        final Like like = getItem(position);
        viewHolder.useritem.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(mContext, UserInfoActivity.class);
                intent.putExtra(Constants.TAG_USER, like.creator);
                mContext.startActivity(intent);
            }
        });
        viewHolder.usericon.setImageDrawable(ResFinder.getDrawable("morentuf"));
        viewHolder.usericon.setImageUrl(like.creator.iconUrl);
        viewHolder.username.setText(like.creator.name);
//        viewHolder.usericon.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View view) {
//                Intent intent = new Intent(mContext, UserInfoActivity.class);
//
//                intent.putExtra(Constants.TAG_USER, like.creator);
//                mContext.startActivity(intent);
//            }
//        });
        if (like.creator.gender.equals(CommUser.Gender.MALE)) {
            viewHolder.usersex.setSelected(false);
        } else {
            viewHolder.usersex.setSelected(true);
        }
//        Log.e("com.draw", "source = " + like.creator.source);
//        OtherUserRequestUtils.getInstance(mContext).OtherUser(like.creator);
//        info = OtherUserRequestUtils.getInstance(mContext).getInfo();
//        Log.e("com.draw", "info = " + info);
//        viewHolder.usersex.setText(StringUtil.age(TimeUtil.getStrTime5(info.getBirthday())) + "岁");
    }

    public FeedLikeAdapter(Context context) {
        super(context);
        this.mContext = context;
    }

}
